<?php
if ( !defined('IN_ADMINCP') || !defined('IN_SEC') ){
	exit('Access Denied.');
}

$id = abs(intval($_G['gp_id']));

if( $id && !$schedule = fetch('schedule', $id) ){
	$admincp->cpmsg('日程不存在');
}
if( is_post() ){
	$title = $_G['gp_title'] ? htmlspecialchars($_G['gp_title']) : $admincp->cpmsg('请输入日程标题');
	$begin_time = $_G['gp_begin_date'] ? strtotime($_G['gp_begin_date']) : 0;
	$end_time = $_G['gp_end_date'] ? strtotime($_G['gp_end_date']) : 0;

	$data = array(
		'title' => $title,
		'begin_time' => $begin_time,
		'end_time' => $end_time,
		'adminid' => $admincp->adminid
	);

	if( $schedule ){
		$scheduleid = $schedule['id'];
		update('schedule', $schedule['id'], $data);
	}else{
		$scheduleid = DB::Insert('schedule', $data);
	}

	$admincp->success('操作成功', '', '', array(
		'id' => $scheduleid
	));
}

?>